home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 1822 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: wiedmann.neckar-alb.de!jochen
  2. From: jochen@neckar-alb.de (Jochen Wiedmann)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Must I free my linked lists? (GCC)
  5. Date: 23 Jan 1996 13:12:29 GMT
  6. Organization: ISS Internet Service Stuttgart GmbH
  7. Message-ID: <4e2mrt$bc6@iss1.neckar-alb.de>
  8. References: <4dudic$aif@vixen.cso.uiuc.edu>
  9. Reply-To: wiedmann@neckar-alb.de
  10. NNTP-Posting-Host: wiedmann.neckar-alb.de
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. Unknown (Dannyman@uiuc.edu) wrote:
  14. :    I'm writing a program that makes use of dynamic memory allocation through
  15. : linked lists using malloc() ... from an implementation PoV there's no need
  16. : to flush this stuff as after the queue is created it's output and the
  17. : program exits. My question is;
  18.  
  19. :    "When my program exits, is the dynamic memory in the queues returned to
  20. : the system or is a "memory hole" left, so that I should actually go back and
  21. : return all the memory in my program ..."
  22.  
  23. You can be sure, if
  24.  
  25.     1.) You are using a version of malloc(), that isn't broken.
  26.         The malloc() coming with your C compiler can be assumed
  27.         to work fine.
  28.     2.) Your program exits in the correct way by calling exit()
  29.         or returning from main().
  30.     3.) You are *sure*, that there are no other functions obtaining
  31.         memory from the system. Examples:
  32.  
  33.         OpenWindow()
  34.         AllocDosObject()
  35.         Open()
  36.  
  37.         These are all using AllocMem, AllocPooled or something similar.
  38.         The memory obtained by them is released using the respective
  39.         counterpart: CloseWindow(), FreeDosObject() or Close(). The
  40.         atexit() function is a good choice, if you want to be sure,
  41.         that these are being called.
  42.  
  43.  
  44. Bye,
  45.  
  46. Jochen
  47.